<template>
  <div>
  </div>
</template>
<script>
import { bindWxApi } from '@/api/gasStationManage/accountManage'

export default {
  created () {
    const query = this.$route.query
    if (Object.keys(query).length && query.code) {
      this.bindWxByCode()
    }
  },
  methods: {
    async bindWxByCode () {
      const wxCode = this.$route.query.code
      const userId = this.$route.query.userId
      try {
        const { code, message } = await bindWxApi({wxCode, userId})
        window.parent.postMessage({code, message, source: 'bindWxPage'}, window.location.origin)
      } catch (error) {
        console.log(error)
      }
    },
  }
}
</script>
